//首页
import {Tab, TabItem,dateFormat} from 'vux'
import {mapActions} from "vuex"
import {getSession,baseInfo} from "../../js/base"
import {requestWithLoading,requestNoLoading} from "../../js/request"
import mesList from "../mesList/mesList.vue"

export const main = {
  components: {
    Tab,
    TabItem,
    mesList
  },
  data() {
    return {
      listFlag:0,
      pendingList: [],
      completeList:[]
    }
  },
  methods: {
    init() {
      this.headerChange(getSession("header") || "");
      this.getPendingList();
    },
    getPendingList() {
      let v = {pageNum: '1', phone: baseInfo.phone, pageSize: 60};
      requestWithLoading("get_remainByMobile", v, (data)=>{
        this.pendingList = data.res.map(function (i) {
          i.createTime = dateFormat(i.CREATE_DATE);
          i.title = i.TITLE;
          i.s_type = i.STAT == 1 ? '已办' : '待办';
          i.imgUrl = "./static/img/e01.png";
          return i;
        });
      })
    },
    getCompleteList() {
      if (this.completeList.length){
            return;
      }
      let v = {pageNum: '1', phone: baseInfo.phone, pageSize: 60};
      requestWithLoading("get_completeByMobile", v, (data)=>{
        this.completeList = data.res.map(function (i) {
          i.createTime = dateFormat(i.CREATE_DATE);
          i.title = i.TITLE;
          i.s_type ="办结";
          i.imgUrl = "./static/img/e01.png";
          return i;
        });
      })
    },
    changeList(index){
      if (index == 1){
        this.getCompleteList();
      }
      this.listFlag = index;
    },
    go_dt(v){
      this.headerChange("快报详情");
      this.tpListChange(false);
      let data = {
        phone: baseInfo.phone,
        process_instance_id: v.PROCESS_ID,
        process_task_id: v.CURRENT_TASK_ID,
        businesskey: v.BUSSNESS_ID
      };
      requestNoLoading("get_findDayTaskForm",data,(t)=>{
        this.tpListChange(t);
      });
      this.$router.push({name:"tpD"});
    },
    ...mapActions([
      "headerChange",
      "tpListChange",
    ])
  },
  mounted() {
    this.init();
  }
}
